home *** CD-ROM | disk | FTP | other *** search
- /* GNUPLOT -- gnugraph.trm */
- /*
- * Copyright (C) 1993
- *
- * Permission to use, copy, and distribute this software and its
- * documentation for any purpose with or without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation.
- *
- * Permission to modify the software is granted, but not the right to
- * distribute the modified code. Modifications are to be distributed
- * as patches to released version.
- *
- * This software is provided "as is" without express or implied warranty.
- *
- * This file is included by ../term.c.
- *
- * This terminal driver supports:
- * GNU plot(5) graphics language
- *
- * AUTHORS
- * Tony Richardson from the unixplot.trm by Colin Kelley, Thomas Williams,
- * and Russell Lang and from post.trm by Russell Lang.
- *
- * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
- *
- * This version of the 'unixplot' driver produces device independent
- * output. I've chosen parameter values so that the PostScript output
- * produced by plot2ps is 5" x 3". You can use the 'set size' command
- * to get output up to 8.25" x 8.25", i.e. size values larger than
- * 1 are okay.
- */
-
- /*
- Unixplot library writes to stdout. A fix was put in place by
- ..!arizona!naucse!jdc to let set term and set output redirect
- stdout. All other terminals write to outfile.
- */
-
- /* This is a device independent format, so the output should look
- * look "reasonable" on any output device. I set things up there so
- * that the output of plot2ps is 5" x 3" (standard GNUPLOT size).
- * You can use GNUPLOT's size command to obtain plots to almost the
- * 8.25" x 8.25" limit.
- */
-
- char up_font[MAX_ID_LEN+1] = "Courier" ; /* name of font */
- int up_fontsize = 10;
-
- /* plot2ps produces a 8.25" x 8.25" square. */
- #define UP_SCREENX 32768
- #define UP_SCREENY 32768
- #define UP_SCRXINC 8.25
- #define UP_SCRYINC 8.25
-
- /* We want a 5" x 3" graph by default. */
- #define UP_XINCHES 5
- #define UP_YINCHES 3
- /* UP_XMAX = (UP_SCREENX*UP_XINCHES)/UP_SCRXINC
- UP_YMAX (UP_SCREENY*UP_YINCHES)/UP_SCRYINC */
- #define UP_XMAX 19859
- #define UP_YMAX 11565
-
- #define UP_XLAST (UP_XMAX - 1)
- #define UP_YLAST (UP_YMAX - 1)
-
- /* UP_VCHAR = ((UP_FONTSIZE*UP_YMAX)/(UP_YINCHES*72))
- = UP_FONTSIZE*UP_VFONTSC
- UP_HCHAR = ((UP_FONTSIZE/2)*UP_XMAX)/(UP_XINCHES*72))
- = UP_FONTSIZE*UP_HFONTSC
- */
-
- #define UP_VFONTSC 53.5
- #define UP_VCHAR 535 /* 10 * VFONTSC */
- #define UP_HFONTSC 27.6
- #define UP_HCHAR 276 /* 10 * HFONTSC */
-
- #define UP_VTIC (UP_YMAX/80)
- #define UP_HTIC (UP_XMAX/80)
-
- /* These offsets center plot2ps output in the middle of the page. The
- * amount of resizing that can be done is limited. */
- /*
- * #define UP_XOFF 6454
- * #define UP_YOFF 10601
- */
-
- /* These offsets give a 1" offset from the lower left corner. This
- * gives a greater range of permissible values in GNUPLOT's size
- * command. */
- #define UP_XOFF 3972
- #define UP_YOFF 3972
-
- enum JUSTIFY up_justify=LEFT;
-
- UP_options()
- {
- extern struct value *const_express();
- extern double real();
-
- if(!END_OF_COMMAND) {
- if(almost_equals(c_token,"d$efault")) {
- strcpy(up_font,"Courier");
- up_fontsize = 10;
- term_tbl[term].v_char = (unsigned int)(up_fontsize*UP_VFONTSC);
- term_tbl[term].h_char = (unsigned int)(up_fontsize*UP_HFONTSC);
- c_token++;
- }
- }
-
- if (!END_OF_COMMAND && isstring(c_token)) {
- quote_str(up_font,c_token);
- c_token++;
- }
-
- if (!END_OF_COMMAND) {
- /* We have font size specified */
- struct value a;
- up_fontsize = (int)real(const_express(&a));
- term_tbl[term].v_char = (unsigned int)(up_fontsize*UP_VFONTSC);
- term_tbl[term].h_char = (unsigned int)(up_fontsize*UP_HFONTSC);
- }
-
- sprintf(term_options,"\"%s\" %d",up_font,up_fontsize);
- }
-
- UP_init()
- {
- openpl();
- space(0,0,UP_SCREENX-1,UP_SCREENY-1);
- fontname(up_font);
- fontsize(up_fontsize);
- }
-
-
- UP_graphics()
- {
- erase();
- }
-
-
- UP_text()
- {
- /* Flush here so that output will be complete. */
- fflush(stdout);
- }
-
-
- UP_linetype(linetype)
- int linetype;
- {
- static char *lt[2+5] = {"solid", "longdashed", "solid", "dotted","shortdashed",
- "dotdashed", "longdashed"};
-
- if (linetype >= 5)
- linetype %= 5;
- linemod(lt[linetype+2]);
- }
-
-
- UP_move(x,y)
- unsigned int x,y;
- {
- move(x+UP_XOFF,y+UP_YOFF);
- }
-
-
- UP_vector(x,y)
- unsigned int x,y;
- {
- cont(x+UP_XOFF,y+UP_YOFF);
- }
-
-
- UP_put_text(x,y,str)
- unsigned int x,y;
- char str[];
- {
- UP_move(x,y); /* Don't adjust x and y! It's done in UP_move. */
- switch(up_justify) {
- case LEFT:
- alabel('l','c',str);
- break;
- case CENTRE:
- alabel('c','c',str);
- break;
- case RIGHT:
- alabel('r','c',str);
- break;
- }
-
- }
-
- UP_text_angle(ang)
- int ang;
- {
- rotate(0,0,90*ang);
- return TRUE;
- }
-
- UP_justify_text(mode)
- enum JUSTIFY mode;
- {
- up_justify=mode;
- return TRUE;
- }
-
- UP_reset()
- {
- closepl();
- }
-
-